package cj.web.admin.util;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class ImagePic {
	
    public static void mergeImage(String path,File file1,String level,String name,String fileName) throws IOException {        
        BufferedImage image1 = ImageIO.read(file1);  
  
        BufferedImage combined = new BufferedImage(image1.getWidth(), image1.getHeight(), BufferedImage.TYPE_INT_RGB);  
  
        // paint both images, preserving the alpha channels  
        Graphics g = combined.getGraphics();  
        g.drawImage(image1, 0, 0, null);  
           
        g.setFont(new Font("Microsoft YaHei", Font.BOLD, 160));
        g.setColor(Color.BLACK);
        g.drawString(level, 870, 1120);
        
        g.setFont(new Font("Microsoft YaHei", Font.BOLD, 70));
        g.setColor(Color.BLACK);
        g.drawString(name, 310, 1300);
        
        g.setFont(new Font("Microsoft YaHei", Font.BOLD, 50));
        g.setColor(Color.BLACK);
        g.drawString(level+" 。", 580, 1495);
        g.dispose();
        
        // Save as new image  
        ImageIO.write(combined, "JPG", new File(path, fileName));  
        
    }  
    
    public static void main(String[] args) throws IOException { 
    	String level = "特等奖";
    	String name = "韩敏";
    	String path = "D:\\"; 
    	String fileName ="award_front111.jpg";
        File file1 = new File(path, "award_front.jpg");  
        mergeImage(path,file1,level,name,fileName);  
    }  
}